﻿using Caffeine.Core;
using System;
public class AddressParent : ModelBase
{
    #region Addresses Property

    [ModelBackingProperty(typeof(AddressViewModel), "Addresses", ModelBase.StandardBehaviors, true, true)]
    protected readonly ModelCollection<AddressViewModel> _Addresses = null; //Will be set by reflection.

    /// <summary>
    /// Gets the Addresses property
    /// </summary>
    public ModelCollection<AddressViewModel> Addresses
    {
        get { return _Addresses; }
    }

    /// <summary>
    /// Gets the Addresses.IsDirty flag. This property supports change notification. If the Addresses.IsDirty flag changes,
    /// it will cause a change notification event for this property. This property must follow the [Addresses + "IsDirty"] convention for change events to work correctly.
    /// </summary>
    public bool AddressesIsDirty
    {
        get { return Addresses.IsDirty; }
    }

    /// <summary>
    /// Gets the Addresses.IsInvalid flag. This property supports change notification. If the Addresses.IsInvalid flag changes,
    /// it will cause a change notification event for this property. This property must follow the [Addresses + "IsInvalid"] convention for change events to work correctly.
    /// </summary>
    public bool AddressesIsInvalid
    {
        get { return Addresses.IsInvalid; }
    }

    /// <summary>
    /// Gets the Addresses.ValidationErrors enumeration. This property supports change notification. If the Addresses.ValidationErrors enumeration changes,
    /// it will cause a change notification event for this property. This property must follow the [Addresses + "ValidationErrors"] convention for change events to work correctly.
    /// </summary>
    public System.Collections.Generic.IEnumerable<ValidationError> AddressesValidationErrors
    {
        get { return Addresses.ValidationErrors; }
    }

    #endregion

    protected override void OnInitialized()
    {
        base.OnInitialized();

        for (Int32 index = 0; index < 10000; index++)
        {
            Addresses.Add(CreateModel<AddressViewModel>());
        }
    }
}